import { _decorator, Component, director, Node } from 'cc';
import { SSS_Consts } from "../../../../Script/Data/SSS_Consts";
import CircleTheCat_GameManager from "../../CircleTheCat_GameManager";
import { SSS_AudioManager } from 'db://assets/Script/Manager/SSS_AudioManager';

const { ccclass, property } = _decorator;

@ccclass('CircleTheCatGamePanel')
export default class CircleTheCat_GamePanel extends Component {
    static Instance: CircleTheCat_GamePanel;
    @property(Node)
    Button_back: Node | null = null;
    @property(Node)
    Button_refresh: Node | null = null;
    // @property(Label)
    // Label_score: Label = null;
    // @property(Label)
    // Label_highScore: Label = null;
    onLoad() {
        CircleTheCat_GamePanel.Instance = this;
    }
    ShowOn() {
        this.node.active = true;
        this.AddListener();
        this.Refresh();
    }
    ShowOff() {
        this.node.active = false;
        this.RemoveListener();
    }
    Refresh() {
        this.Refresh_score();
    }
    Refresh_score() {
    }
    AddListener() {
        this.Button_back.on(Node.EventType.TOUCH_END, this.On_Button_back, this);
        this.Button_refresh.on(Node.EventType.TOUCH_END, this.On_Button_refresh, this);

    }
    RemoveListener() {
        this.Button_back.off(Node.EventType.TOUCH_END, this.On_Button_back, this);
        this.Button_refresh.off(Node.EventType.TOUCH_END, this.On_Button_refresh, this);
    }
    On_Button_back() {
        director.loadScene(SSS_Consts.SceneName.MainScene);

        SSS_AudioManager.PlayButtonAudio();
    }
    On_Button_refresh() {
        CircleTheCat_GameManager.Instance.Replay();

        SSS_AudioManager.PlayButtonAudio();
    }
}

/** 调试 */
window["CircleTheCat_GamePanel"] = CircleTheCat_GamePanel;